package com.examsystem.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.examsystem.common.ResultJson;
import com.examsystem.entity.exame_questionsbank;
import com.examsystem.service.QuesBankService;

/**
 * 题库crud
 * 
 * @author An-Il
 *
 */
@RestController
@RequestMapping("/tkgl")
public class QuesBankController {

	@Autowired
	private QuesBankService qBankService;

	// 查询考题（分页）
	@PostMapping("/selectQBList")
	public ResultJson selectQBList(@RequestParam(defaultValue = "1") Integer page,
			@RequestParam(defaultValue = "10") Integer pageSize) {
		ResultJson result = null;
		result = qBankService.selectQBList(page, pageSize);
		return result;
	}

	// 模糊查询(分页）
	@PostMapping("/selectByExample")
	public ResultJson selectByExample(exame_questionsbank questionsbank,
			@RequestParam(defaultValue = "DESC") String Sort, @RequestParam(defaultValue = "1") Integer page,
			@RequestParam(defaultValue = "10") Integer pageSize) {
		ResultJson result = null;
		result = qBankService.selectByExample(questionsbank, Sort, page, pageSize);
		return result;
	}

	// 根据id修改
	@PostMapping("/updateByKey")
	public ResultJson updateByKey(exame_questionsbank questionsbank) {
		ResultJson result = null;
		result = qBankService.updateByKey(questionsbank);
		return result;
	}

	// 根据id删除
	@PostMapping("/deleteByKey")
	public ResultJson deleteByKey(exame_questionsbank questionsbank) {
		ResultJson result = null;
		result = qBankService.deleteByKey(questionsbank);
		return result;
	}

}
